package cn.itcast.homework.config;

import cn.itcast.homework.interceptors.MyHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 虎哥
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 调用registry的方法，添加自定义拦截器。指定拦截器要拦截的路径
        registry.addInterceptor(new MyHandlerInterceptor()).addPathPatterns("/**");
    }
}
